
#include "StationaryObject.h"


/* Constructor
 * 
 */
StationaryObject::StationaryObject() :
	m_ObjectType(OBSTACLE),
	m_Tag(false),
	m_Pos(Ogre::Vector3::ZERO),
	m_Scale(Ogre::Vector3(1)),
	m_BoundingRadius(500.0),
	m_TimeElapsed(0.0)
{
	m_ID = GameServices::ObjectManager()->GetStationaryObjectCount();
}

/* Destructor
 * 
 */
StationaryObject::~StationaryObject()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::~StationaryObject() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::~StationaryObject() ");
	}
}

/* Initialize
 * 
 */
void StationaryObject::Initialize()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::Initialize() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::Initialize() ");
	}
}

/* UpdateStarted(const Ogre::FrameEvent& gameTime)
 * 
 */
void StationaryObject::UpdateStarted(const Ogre::FrameEvent& gameTime)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::UpdateStarted(const Ogre::FrameEvent& gameTime) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::UpdateStarted(const Ogre::FrameEvent& gameTime) ");
	}
}

/* UpdateEnded(const Ogre::FrameEvent& gameTime)
 * 
 */
void StationaryObject::UpdateEnded(const Ogre::FrameEvent& gameTime)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::UpdateEnded(const Ogre::FrameEvent& gameTime) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::UpdateEnded(const Ogre::FrameEvent& gameTime) ");
	}
}

/* Cleanup()
 * 
 */
void StationaryObject::Cleanup()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::Cleanup() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::Cleanup() ");
	}
}

/* Draw()
 * Not used
 */
void StationaryObject::Draw()
{
}

/* HandleMessage(int message)
 * Not used
 */
bool StationaryObject::HandleMessage(int message)
{
	return true;
}

/* GetPosition()
 * Returns Vector3 m_Pos
 */
Ogre::Vector3 StationaryObject::GetPosition()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::GetPosition() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Position " + 
			Ogre::StringConverter::toString(m_Pos));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::GetPosition() ");
	}
	return m_Pos;
}

/* SetPostion(Ogre::Vector3 pos)
 * Sets Vector3 m_Pos
 */
void StationaryObject::SetPostion(Ogre::Vector3 pos)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetPostion(Ogre::Vector3 pos) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Position " + 
			Ogre::StringConverter::toString(pos));
	}

	m_Pos = pos;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetPostion(Ogre::Vector3 pos) ");
	}
}

/* GetBRadius()
 * Returns double m_BoundingRadius
 */
double StationaryObject::GetBRadius()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::GetBRadius() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Bounding Radius " + 
			Ogre::StringConverter::toString((int)m_BoundingRadius));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::GetBRadius() ");
	}
	return m_BoundingRadius;
		
}

/* SetBRadius(double r)
 * Sets double m_BoundingRadius
 */
void StationaryObject::SetBRadius(double r)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetBRadius(double r) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Bounding Radius " + 
			Ogre::StringConverter::toString((int)r));
	}

	m_BoundingRadius = r;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetBRadius(double r) ");
	}
}

/* GetID()
 * Returns integer m_ID
 */
int StationaryObject::GetID()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::GetID() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Stationary ID #" + 
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::GetID() ");
	}
	return m_ID;
}

/* SetID(int id)
 * Sets integer m_ID
 */
void StationaryObject::SetID(int id)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetID(int id) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Autonomous ID is " + 
			Ogre::StringConverter::toString(id));
	}

	m_ID = id;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetID(int id) ");
	}
}

/* IsTagged()
 * Returns a bool with the status of m_Tag
 */
bool StationaryObject::IsTagged()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::IsTagged() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Is AutoObject Taged? " + 
			Ogre::StringConverter::toString(m_Tag, true));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::IsTagged() ");
	}

	return m_Tag;
}

/* Tag()
 * Sets boolean m_Tag to true
 */
void StationaryObject::Tag()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::Tag() | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("<= <= <= <= <= <= Tagged StationaryObject " + Ogre::StringConverter::toString(m_ID));

	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::Tag() ");
	}

	m_Tag = true;
}

/* UnTag()
 * Sets boolean m_Tag to false
 */
void StationaryObject::UnTag()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::UnTag() | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("=> => => => => => => Untagged StationaryObject " + Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::UnTag() ");
	}
	m_Tag = false;
}

/* GetScale()
 * Returns the integer m_Scale
 */
Ogre::Vector3 StationaryObject::GetScale()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::GetScale() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Scale is " + 
			Ogre::StringConverter::toString(m_Scale));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::GetScale() ");
	}
	return m_Scale;
}

/* SetScale(Ogre::Vector3 nScale)
 * Sets the Vector3 m_Scale
 */
void StationaryObject::SetScale(Ogre::Vector3 nScale)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetScale(Ogre::Vector3 nScale) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Scale is " + 
			Ogre::StringConverter::toString(nScale));
	}

	m_Scale = nScale;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetScale(Ogre::Vector3 nScale) ");
	}
}

/* SetScale(double nScale)
 * Sets the individual components of the Vector3 m_Scale
 */
void StationaryObject::SetScale(double nScale)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetScale(double nScale) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetScale(double nScale) ");
	}

	m_Scale = Ogre::Vector3(nScale);
}

/* GetObjectType()
 * Returns the enum ObjectType m_ObjectType
 * The enumeration is declared in IObject.h
 */
ObjectType StationaryObject::GetObjectType()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::GetObjectType() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(Ogre::StringConverter::toString(m_ObjectType));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::GetObjectType() ");
	}
	return m_ObjectType;
}

/* SetObjectType(ObjectType nType)
 * Sets the enum ObjectType m_ObjectType
 * The enumeration is declared in IObject.h
 */
void StationaryObject::SetObjectType(ObjectType nType)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetObjectType(ObjectType nType) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(Ogre::StringConverter::toString(nType));
	}

	m_ObjectType = nType;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetObjectType(ObjectType nType) ");
	}
}

/* Write(std::ostream& os)
 * Not used
 */
void StationaryObject::Write(std::ostream& os)
{}

/* Read(std::istream& is)
 * Not used
 */
void StationaryObject::Read(std::istream& is)
{}

/* TimeElapsed()
 * Return m_TimeElapsed
 */
double StationaryObject::TimeElapsed()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::TimeElapsed() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::TimeElapsed() ");
	}
	return m_TimeElapsed;
}

/* SetName(Ogre::String nName)
 * Set m_Name
 */
void StationaryObject::SetName(Ogre::String nName)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::SetName(Ogre::String nName) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_Name = nName;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::SetName(Ogre::String nName) ");
	}
}

/* GetName()
 * Return m_Name
 */
Ogre::String StationaryObject::GetName()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER StationaryObject::GetName() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT StationaryObject::GetName() ");
	}
	return m_Name;
}